#ifndef JY901_H
#define JY901_H

#include "stm32f4xx.h"
#include "main.h"

#include "lcd_key_led.h"


#define  	PI_NVIC    				0

#define 	PI_START_BYTE 			0xa5
#define 	PI_RX_BUF_NUM 			16u             //11*2

#define     RED_FRAME_IDENTI    	0x08            //返回红点绝对坐标
#define     FIV_FRAME_IDENTI        0x07            //矩形的五个点位，顺时针返回点位，最后为中心点
#define     RAB_FRAME_IDENTI    	0x02            //双点的Delta

#define     RED_FRAME_LENTH         0x08            //8
#define     FIV_FRAME_LENTH         0x18            //24
#define     RAB_FRAME_LENTH         0x08            //8

//树莓派返回两种类型的帧
//1-颜色点坐标  0xa5  RGB_FRAME_IDENTI   X_RED_L  X_RED_H  Y_RED_L  Y_RED_H  X_GREEN_L  X_GREEN_H  Y_GREEN_L  Y_GREEN_H  SUM
//2-矩形点坐标  0xa5  FOUR_FRAME_IDENTI  X_NUM1_L X_NUM1_H Y_NUM1_L Y_NUM1_H X_NUM2_L X_NUM2_H Y_NUM2_L Y_NUM2_H X_NUM3_L   X_NUM3_H   Y_NUM3_L   Y_NUM3_H  X_NUM4_L   X_NUM4_H Y_NUM4_L   Y_NUM4_H SUM


//#define  	ANGLE_TO_RAD        0.01745329251943295f


typedef struct
{
	int16_t x_delta;
	int16_t y_delta;
} delta_msg;                        //红绿的位置差值   

typedef struct
{
	int16_t x;
	int16_t y;
} point_locat;



typedef struct
{
	delta_msg red_green_delta;
	point_locat red_point;
	point_locat point[4];
	point_locat center_point;
}   pi_reveive_data;





void PI_init(void);
const pi_reveive_data * get_pi_data_point(void);

#endif
